Impact of log parsing on deep learning-based anomaly detection

Software systems log massive amounts of data, recording important runtime information. Such logs are used, for example, for log-based anomaly detection, which aims to automatically detect abnormal behaviors of the system under analysis by processing the information recorded in its logs. Many log-based anomaly detection techniques based on deep learning models include a pre-processing step called log parsing. However, understanding the impact of log parsing on the accuracy of anomaly detection techniques has received surprisingly little attention so far. Investigating what are the key properties log parsing techniques should ideally have to help anomaly detection is therefore warranted. In this paper, we report on a comprehensive empirical study on the impact of log parsing on anomaly detection accuracy, using 13 log parsing techniques, seven anomly detection techniques (five based on deep learning and two based on traditional machine learning) on three publicly available log datasets. Our empirical results show that, despite what is widely assumed, there is no strong correlation between log parsing accuracy and anomaly detection accuracy, regardless of the metric used for measuring log parsing accuracy. Moreover, we experimentally confirm existing theoretical results showing that it is a property that we refer to as distinguishability in log parsing results—as opposed to their accuracy—that plays an essential role in achieving accurate anomaly detection.


Introduction
Software system execution logs provide valuable information about the runtime behavior of the system, which is essential for monitoring and troubleshooting.Among many log analysis approaches, log-based anomaly detection has been actively studied to automatically detect abnormal behaviors of the system under analysis by processing the information recorded in logs [16].Recently, anomaly detection techniques based on Deep Learning (DL) models, such as Long Short-Term Memory (LSTM) [9,31,52] and Convolutional Neural Networks (CNNs) [29], have shown promising results.
One common aspect of most anomaly detection techniques is having a preprocessing step called log parsing (also known as log template identification).This step is needed because anomaly detection techniques require structured logs to automatically process them, whereas input logs are often free-formed or semistructured, as generated by logging statements (e.g., printf() and logger.info()) in the source code.Many log parsing techniques have also been developed to automatically convert unstructured input logs into structured logs [53].
The frequent combination of log parsing and anomaly detection clearly implies the importance of the former for the latter.Nevertheless, assessing in a systematic way the impact of log parsing on anomaly detection has received surprisingly little attention so far.Only recently, Shin et al. [44] investigated what ideal log parsing results are in terms of accurate anomaly detection, but purely from a theoretical standpoint.Le and Zhang [27] empirically showed that different log parsing techniques, among other potential factors, can significantly affect anomaly detection accuracy, but the accuracy of log parsing results was not adequately measured, and the correlation between log parsing accuracy and anomaly detection accuracy was not reported.Fu et al. [12] attempted to address the issue by evaluating log parsing and anomaly detection accuracy.However, they relied on a single log parsing accuracy metric [24], and the log parsing results used to evaluate anomaly detection techniques were based on less than 1% of all logs used, which limits the validity of the findings.
To systematically investigate the impact of log parsing on anomaly detection while addressing the issues of the aforementioned studies, this paper reports on an empirical study, in which we performed a comprehensive evaluation using 13 log parsing techniques, seven anomaly detection techniques-five based on deep learning and two based on traditional machine learning-on three publicly available log datasets.We considered all three log parsing accuracy metrics (i.e., grouping accuracy [53], parsing accuracy [6], and template accuracy [24]) proposed in the literature.
Against all assumptions, our results show that there is no strong correlation between log parsing accuracy and anomaly detection accuracy, regardless of the metric used for measuring log parsing accuracy.In other words, accurate log pars-ing results do not necessarily increase anomaly detection accuracy.To better understand the phenomenon at play, we investigated another property of log parsing, distinguishability, a concept proposed by Shin et al. [44] that was theoretically shown to relate to anomaly detection accuracy.Our empirical results confirm that, as far as anomaly detection is concerned, distinguishability in log parsing results is the property that really matters and should be the key target of log parsing.
In summary, the main contributions of this paper are: the systematic and comprehensive evaluation of the impact of log parsing on anomaly detection; -the investigation of the impact of the distinguishability of log parsing results on anomaly detection.
The rest of the paper is organized as follows.Section 2 provides basic information used throughout the paper, including the definitions of logs, messages, and templates, as well as an overview of log parsing and anomaly detection.Section 3 motivates our study and introduces the research questions.Section 4 describes the experimental design, including the log datasets, log parsing techniques, and anomaly detection techniques used in the experiments.Section 5 presents the experimental results.Section 6 discusses the practical implications, derived from the results, for the application of log parsing in the context of anomaly detection.Section 7 surveys the related work.Section 8 concludes the paper and provides directions for future work.

Background
In this section, we provide an overview of the main concepts that will be used throughout the paper.We first introduce the definitions of logs, messages, and log templates ( § 2.1).We then explain the concept of log parsing (also known as log template identification) and illustrate different log parsing accuracy metrics proposed in the literature ( § 2.2).We discuss log-based anomaly detection and the corresponding accuracy metrics in § 2.3.Finally, we summarize the recent theoretical results on ideal log parsing for accurate anomaly detection, introducing the concept of distinguishability for log parsing results ( § 2.4).

Logs, Messages, and Templates
A log is a sequence of log entries * .A log entry contains various information about the event being logged, including a timestamp, a logging level (e.g., INFO, DEBUG), and a log message.A log message can be further decomposed into fixed and variable parts since it is generated by executing a logging statement that can have both fixed (hard-coded) strings and program variables in the source code.For example, the execution of the logging statement "logger.info("Deletingblock " + blkID + " file " + fileName)" when the program variables blkID and fileName evaluate to blk-1781 and /hadoop/dfs, respectively, will generate a log entry "11:22:33 INFO Deleting block blk-1718 file /hadoop/dfs" where the log message "Deleting block blk-1718 file /hadoop/dfs" can be decomposed into the fixed parts (i.e., "Deleting block" and "file") and the variable parts (i.e., "blk-1718" and "/hadoop/dfs").A (log message) template masks the various elements of each variable part with a special character "<*>"; this representation is widely used in log-based analyses (e.g., log parsing [14,21], anomaly detection [9,52], and logbased testing [10,19]) when it is important to focus on the event types captured by a log message.

Log Parsing (Log Template Identification)
Although software execution logs contain valuable information about the run-time behavior of the software system under analysis, they cannot be directly processed by log-based analysis techniques that require structured input logs (containing templates) instead of free-formed log messages.Extracting log templates from log messages is straightforward when the source code with the corresponding logging statements is available.However, often the source code is unavailable, for example, due to the usage of 3rd-party, proprietary components.This leads to the problem of log parsing (log template identification): How can we identify the log templates of log messages without accessing the source code?
Zhu et al. [53] observed that log parsing can be considered as a clustering process where log messages with the same template are clustered into the same group.Based on this idea, they proposed the GA metric to assess if log messages are correctly grouped.Specifically, GA is defined as the ratio of log messages correctly parsed by the log parsing approach under evaluation over the total number of log messages, where a log message is correctly parsed when its log message group is the same as the ground truth (i.e., a group generated by oracle templates).
Dai et al. [6] later proposed PA, to address the issue that GA only considers message groups, not the equivalence between the templates identified by the log parsing approach under evaluation and the oracle templates.Although having correctly grouped messages would be enough in some cases (e.g., detecting anomalies based on the sequence of template IDs without considering the content of the templates [9]), correctly identified templates (i.e., templates identical to the corresponding oracle ones) matter when the fixed parts of templates are used (e.g., detecting anomalies based on the semantic information in the templates [52]).To this end, PA replaces the definition of a correctly parsed log message in GA as follows: a log message is correctly parsed when its identified template is identical to the oracle template.
Khan et al. [24] recently proposed the TA metric, since both GA and PA are defined based on the number of correctly parsed log messages and, therefore, can be misleading, especially when there are many repeated messages (e.g., heartbeat messages).Specifically, they introduced Precision-TA (PTA) and Recall-TA (RTA), where PTA is defined as the number of correctly identified templates over the total number of identified templates and RTA is defined as the number of correctly identified templates over the total number of oracle templates.Moreover, FTA (short for "F1-measure TA") is the harmonic mean of PTA and RTA.

Anomaly Detection
(Log-based) anomaly detection is a technique that aims to identify anomalous patterns, recorded in input logs, that do not conform to the expected behaviors of the system under analysis [16].It takes as input a sequence of log templates and determines whether the given sequence represents a normal behavior of the system or not.
With the recent advances in Deep Learning (DL), many anomaly detection approaches, which leverage DL models to learn various aspects of log template sequences of normal and abnormal behaviors and classify them, have been proposed in the literature; for example, DeepLog [9], LogAnomaly [31], and LogRobust [52] are based on Long Short-Term Memory based (LSTM), CNN [29] is based on Convolutional Neural Network, and PLELog [51] is based on Gated recurrent units (GRUs).
To assess the accuracy of anomaly detection approaches, it is common practice to use standard metrics from the information retrieval domain, such as Precision, Recall, and F1-Score.These metrics are defined as follows: Precision = TP TP+FP , Recall = TP TP+FN , and F1-score = 2×Precision×Recall Precision+Recall where TP (True Positive) is the number of abnormal logs correctly identified by the model, FP (False Positive) is the number of normal logs incorrectly identified as anomalies by the model, and FN (False Negative) is the number of abnormal logs incorrectly identified as normal.

Ideal Log Parsing Results for Accurate Anomaly Detection
Given the dependency of anomaly detection on log parsing, Shin et al. [44] presented a theoretical analysis on ideal log parsing results for accurate anomaly detection.The idea behind the analysis is that log parsing can be regarded as the abstraction of log messages, where some tokens in the messages are converted to variable parts.Then, if normal and abnormal logs are over-abstracted by log parsing so that they are indistinguishable from each other, it is clear that anomaly detection, which takes as input the parsed logs (i.e., abstracted logs, sequences of templates), cannot distinguish normal from abnormal logs.Based on this idea, they formally defined the concept of distinguishability as a property of log parsing results and showed that it is an essential condition for ideal log parsing results.
Specifically, let M be a set of log messages and L be a set of logs where a log l ∈ L is a sequence of log messages ⟨m 1 , m 2 , . . ., mn⟩.Also, let Ln ⊆ L be a set of normal logs and La ⊆ L be a set of abnormal logs such that Ln ∩ La = ∅ and Ln ∪ La = L. Given M and a set of templates (i.e., log parsing results) T , an abstraction function τ : M → T that represents a generic log parsing approach can be defined.Based on τ , an abstraction of a log l = ⟨m 1 , m 2 , . . ., mn⟩ can be defined as τ * (l) = ⟨τ (m 1 ), τ (m 2 ), . . ., τ (mn)⟩.Similarly, an abstraction of a set of logs L can be defined as τ * * (L) = {τ * (l) | l ∈ L}.Notice that τ * * (L) represents a log parsing result for a set of logs L.
The notion of distinguishability can be defined as follows: τ distinguishes Ln and La if and only if τ * * (Ln) ∩ τ * * (La) = ∅.In other words, a log parsing approach distinguishes between normal and abnormal logs if and only if they are still distinguishable after log parsing.When τ distinguishes Ln and La, τ * * (L) for L = Ln ∪ La is called d-maintaining, meaning that the distinguishability between Ln and La is maintained in the log parsing result.

Motivation
As discussed in Section 2, log parsing converts unstructured logs into structured ones, which can then be processed by log-based analysis techniques like anomaly detection.It is quite natural to speculate that log parsing results can affect anomaly detection results.Intuitively, the research literature has assumed that inaccurate log parsing results leads to inaccurate anomaly detection results.However, this hypothesis has not been fully investigated in the literature, except for one empirical study [27] and one analytical investigation [44].
Le and Zhang [27] recently presented an empirical work investigating several aspects that can impact Deep Learning (DL)-based anomaly detection approaches, such as training data selection, data grouping, class distribution, data noise, and early detection ability.One of their experiments considering data noise assessed the impact of noise deriving from log parsing results.Specifically, they used four log parsing techniques (Drain [14], Spell [8], AEL [21], and IPLoM [30]) to generate log parsing results for two log datasets (BGL [38] and Spirit [38]).Then, for each log dataset, they used the different log parsing results as input of five anomaly detection approaches (DeepLog [9], LogAnomaly [31], PLELog [51], LogRobust [52], and CNN [29]), and measured the accuracy of the latter.Their experimental results showed that log parsing approaches highly influence the accuracy of anomaly detection; for example, the F1-Score of DeepLog on Spirit logs [38] decreases from 0.755 to 0.609 when Drain is used instead of IPLoM for log parsing.
Although this is the first clear evidence showing the impact of log parsing results on anomaly detection accuracy, the scope of the underlying study is limited.For example, it simply uses different log parsing results (produced by different tools) without quantitatively assessing the accuracy of the log parsing tools; therefore, the relationship between log parsing accuracy and anomaly detection accuracy remains unclear.To this end, we define our first research question as follows: RQ1 -To which extent does the accuracy of log parsing affect the accuracy of anomaly detection?
As summarized in Section 2.4, Shin et al. [44] recently proposed a theoretical framework determining the ideal log parsing results for anomaly detection by introducing the concept of "distinguishability" for log parsing results.It is argued that, rather than accuracy as previously assumed, what really matters is the extent to which log parsing results are distinguishable.However, to the best of our knowledge, there is no empirical work assessing quantitatively distinguishability in log parsing results and its impact on anomaly detection accuracy.Therefore, we define our second research question as follows: RQ2 -How does the accuracy of anomaly detection vary with distinguishability of log parsing results?
Answering the above questions will have a significant impact on both research and industry in the field of log-based anomaly detection.For example, if the answer to the first question is that, regardless of the log parsing accuracy metrics, there is no relationship between log parsing accuracy and anomaly detection accuracy, then it means that there is no need to use the existing accuracy metrics to evaluate log parsing results for anomaly detection.This would completely change the way log parsing tools are evaluated.Similarly, if the answer to the second question is that the distinguishability of log parsing results indeed affects anomaly detection, as expected from the recent theoretical analysis [44], then this must be the focus of log parsing evaluations.As a result, our answers will provide essential insights on better assessing the quality of log parsing techniques for more accurate anomaly detection.

Experimental Design
All experiments presented in this paper were carried out using the HPC facilities of the University of Luxembourg (see https://hpc.uni.lu).Specifically, we used Dual Intel Xeon Skylake CPU (8 cores) and 64GB RAM for running individual log parsing and anomaly detection techniques.

Datasets
To answer the research questions introduced in Section 3, we used publicly available datasets based on the LogHub benchmark [15], which contains a large collection of log messages from various types of systems including operating systems (Linux, Windows, and Mac), distributed systems (BGL, Hadoop, HDFS, Thunderbird, and OpenStack), standalone programs (Proxifier and Zookeeper), and mobile systems (Android).The benchmark has been widely used in various studies focused on log parsing [6,24,53] and anomaly detection [12,27].
Among the benchmark datasets, we selected HDFS, Hadoop, and OpenStack datasets because of the following reasons: (1) they have labels for normal and abnormal logs to be used for assessing the accuracy of anomaly detection techniques and (2) the source code of the exact program version used to generate the logs is publicly available; this allows us to extract correct oracle templates (i.e., ground truth templates) for each log message.The oracle templates are especially important in our study as we need to carefully assess both log parsing accuracy and anomaly detection accuracy.Although the benchmark provides some oracle templates for all log datasets, they are manually generated (without accessing the source code) and cover only 2K log messages randomly sampled for each dataset.As discussed by Khan et al. [24], those manually generated oracle templates are Table 1: Datasets in LogHub benchmark [15] Datasets Anomaly Label Source Code error-prone; therefore, we used the logging statements in the source code to extract correct oracle templates.Table 1 shows all the log datasets in the LogHub benchmark and whether they meet each of the above-mentioned criteria; the rows highlighted in gray meet both criteria.
During our preliminary evaluation, we found an issue with HDFS.The original HDFS logs were too large (11.2 M log messages) to be processed by the slowest anomaly detection technique (i.e., LogAnomaly [31]) when setting a two-day timeout.Due to the large number of experiments we needed to conduct (i.e., all combinations of log parsing and anomaly detection techniques with additional repeats for distinguishable and indistinguishable log parsing results, see § 4.4 and § 4.5), we decided to reduce the log dataset size.As we found that the slowest log parsing technique (i.e., LogAnomaly) could process up to n = 300K messages within 2 hours, we randomly and iteratively removed logs (i.e., sequences of log messages) from the HDFS dataset to reduce it until the total number of remaining messages was less than 300K.Notice that each HDFS log is a sequence of log messages having the same block ID, representing either a normal or abnormal sequence of events.To preserve individual (normal or abnormal) sequences, we randomly selected and removed them by sequence, not by message.Although the resulting reduced dataset is much smaller than the original dataset, it is still representative of the original dataset in terms of the distribution of normal and abnormal log messages.Specifically, the original HDFS dataset consists of 11 175 629 log messages, with 97.43% normal and 2.57% abnormal log messages, and the reduced HDFS dataset mirrors this distribution, with 97.60% normal and 2.40% abnormal log messages.
Table 2 reports on the size of our datasets, in terms of the number of oracle templates (O), the number of all logs (L all ), the number of normal logs (Ln ), the number of abnormal logs (La ), the number of all messages (M all ), the number of messages in normal logs (Mn ), and the number of messages in abnormal logs (Ma ).Note that the number of log messages is the same as the number of log entries (see Section 2.1 for details).

Log Parsing Techniques
We aimed to use as many log parsing techniques as possible, among those available in the literature.Since Khan et al. [24] recently provided a comprehensive evaluation of 14 log parsing techniques (i.e., AEL [21], Drain [14], IPLoM [30], LenMa [43], LFA [36], LKE [11], LogCluster [48], LogMine [13], Logram [6], LogSig [45], MoLFI [32], SHISO [34], SLCT [47], and Spell [8]), we decided to reuse their replication package, including all the aforementioned techniques.However, we had to exclude LKE since our preliminary evaluation results showed that it could not complete its run for all of our log datasets within the 2-day timeout.Notice that we have already reduced our log datasets (in particular, HDFS), as discussed in Section 4.1, based on the slowest anomaly detection technique (i.e., LogAnomaly).Although we could additionally reduce the datasets based on the slowest log parsing technique (i.e., LKE), we found that it would result in small logs that are not representative of the size and complexity of realworld logs.
As a result, we considered 13 log parsing techniques in our experiments.For all the log parsing techniques, we used their default parameters.

Anomaly Detection Techniques
Similar to the case of log parsing techniques, we considered the work of Le and Zhang [27], a recent empirical study that evaluated five DL-based anomaly detection techniques (i.e., DeepLog [9], LogAnomaly [31], LogRobust [52], PLELog [51], and CNN [29]), and decided to use their replication package, including all the aforementioned techniques.For all anomaly detection techniques, we used their default parameters.These techniques are representative of the state of the art of DL-based anomaly detection techniques.
In addition to deep learning models, we included two representative traditional machine learning models, namely Support Vector Machine (SVM) [17] and Random Forest (RF) [3]  † since they are known for their effectiveness in anomaly detection tasks on the HDFS dataset [20,50].
We want to note that the seven anomaly detection techniques used in this paper all require log parsing as a preliminary step.Although a few recent studies [26,35,37] have proposed anomaly detection techniques that do not require log parsing, we did not consider them in our work.This is mainly because our focus is on assessing the impact of log parsing on anomaly detection techniques.We leave the evaluation of techniques that do not require log parsing for future work.

Methodology for RQ1
Recall that RQ1 investigates to what extent the accuracy of log parsing affects the accuracy of anomaly detection.To answer RQ1, for each dataset, we first executed the log parsing techniques to generate log parsing results and computed their accuracy in terms of GA, PA, and FTA (see § 2.2).We then executed the anomaly detection techniques on each of the log parsing results and computed their accuracy in terms of precision (PR), recall (RE), and F1 score.By doing so, we obtained a tuple of accuracy values ⟨GA, PA, FTA, PR, RE , F1 ⟩ for each combination of datasets, log parsing results, and anomaly detection techniques.
For log parsing, we executed each of the log parsing techniques with a 2-day timeout.Since MoLFI is non-deterministic, we executed it three times.In total, we obtained 16 log parsing results (three from the three different executions of MoLFI and 13 from the remaining log parsing techniques) for each dataset.For each log parsing result, we computed ⟨GA, PA, FTA⟩ using the oracle templates (and the messages matching them) for the corresponding datasets.
For anomaly detection, we divided the individual log parsing results into two disjoint sets, i.e., a training set and a test set, using a split ratio of 80:20.Considering the data leakage problem mentioned by Le and Zhang [27], we used the first 80% of the logs (in chronological order) for training and the remaining 20% for testing.We trained the anomaly detection techniques on each of the training sets with a 2-day timeout, and used the corresponding test sets to compute ⟨PR, RE , F1 ⟩.To account for the randomness of anomaly detection techniques, we repeated the train-and-test process five times and used the average F1 score.
As a result, we obtained 224 tuples ⟨GA, PA, FTA, PR, RE , F1 ⟩ from the combinations of two datasets, 16 log parsing results, and seven anomaly detection techniques.

Methodology for RQ2
Recall that RQ2 investigates the relationship between the distinguishability of log parsing results and anomaly detection accuracy.To answer RQ2, we need distinguishable and indistinguishable log parsing results to compare in terms of anomaly detection accuracy.Although the log parsing results generated for RQ1 are available, they are mostly (but not all) distinguishable, leading to unbalanced data for RQ2.To systematically assess the impact of the distinguishability of log parsing results on anomaly detection accuracy using balanced data, we generate pairs of distinguishable and indistinguishable log parsing results.
Specifically, let d(R) be the distinguishability -expressed as a Boolean value, either true (T ) or false (F ) -of a log parsing result R. For each log parsing result R (i.e., the result of executing a log parsing technique for a dataset) generated in the context of RQ1 (i.e., 16 log parsing results for each of the two datasets), we first created a pair of log parsing results ⟨R, R ′ ⟩ by artificially generating R ′ from R such that d(R ′ ) = ¬d(R) using Algorithms 1 and 2, detailed further below.By definition, if R is distinguishable then R ′ will be indistinguishable and vice versa.For the sake of simplicity, we denote the distinguishable result (be it R or R ′ ) as R dst and the indistinguishable one (respectively, either R ′ or R) as R ind .We then executed, for all pairs ⟨R dst , R ind ⟩, all the considered anomaly detection techniques twice: the first time using R dst as input and the second time using R ind as input; for each run of each anomaly detection technique we computed its accuracy in terms of precision, recall, and F1 score.By doing so, we obtained the anomaly detection accuracy scores for pairs of distinguishable (R dst ) and indistinguishable (R ind ) versions of log parsing results, and then compared them.
For the generation of R ′ from R, it is important to minimize the difference between R and R ′ (in terms of both training and testing datasets) while achieving d(R ′ ) = ¬d(R).This is to ensure that if there is a difference in anomaly detection scores between R and R ′ , it is mostly due to distinguishability and not to other differences between R and R ′ (e.g., the number of templates or the size of log parsing results).Furthermore, the testing datasets for R and R ′ should remain the same.To do this, we need to distinguish the two cases when d(R) = T and when d(R) = F , as described below.

Generation of Indistinguishable from Distinguishable Log Parsing Results
When d(R) = T (i.e., R = R dst ), it means that templates for different log messages in R are different enough to distinguish between normal and abnormal logs in R, as explained in Section 2.4.For example, let us consider two logs l 1 = ⟨m 1 , m 2 ⟩ and l 2 = ⟨m 3 , m 4 ⟩ where the templates of the four messages are identified as τ (m 1 ) = t 1 , τ (m 2 ) = t 2 , τ (m 3 ) = t 3 , and τ (m 4 ) = t 2 , respectively, using a log parsing technique τ .Figure 1 shows the logs, messages, and templates.In this case, the log parsing result of τ for {l 1 , l 2 } is distinguishable, as highlighted in blue in the figure, since τ * (l 1 ) = ⟨τ (m 1 ), τ (m 2 )⟩ = ⟨t 1 , t 2 ⟩ and τ * (l 2 ) = ⟨τ (m 3 ), τ (m 4 )⟩ = ⟨t 3 , t 2 ⟩ are different (due to τ (m 1 ) ̸ = τ (m 3 ), i.e., t 1 ̸ = t 3 ).However, if the templates of m 1 and m 3 were the same, then the log parsing result would be indistinguishable.In other words, as highlighted in red in the figure, we can make the distinguishable log parsing result of τ indistinguishable by merging the templates of m 1 and m 3 (e.g., by introducing a dummy log parsing technique τ ′ that behaves the same as τ except for τ ′ (m 1 ) = τ ′ (m 3 ) = t 13 ).Notice that τ ′ changes only (a few) templates, not the corresponding log messages, meaning that the original datasets remain the same.Using this idea, to generate R ′ = R ind from R = R dst , we generated the templates of R ind by iteratively merging the templates of R dst until d(R ind ) = F .Furthermore, to minimize the difference between R dst and R ind in terms of the number of templates (i.e., to minimize the number of templates being merged), we start with merging the templates with the highest number of matching messages in the log.This is based on the intuition that the more messages affected by merging templates, the more likely normal and abnormal logs are to become indistinguishable.Recall that we only change the templates, not their log messages.
Although merging templates to generate indistinguishable log parsing results might look artificial, it is indeed realistic to some extent.In practice, a log parsing result would be indistinguishable only when a log parsing technique fails to identify proper templates that can sufficiently "distinguish" normal and abnormal log sequences.Therefore, merging templates in the distinguishable log parsing results mimics the behavior of such imperfect log parsing techniques, leading to indistinguishable log parsing results.
One might also object that artificially merging templates corresponding to different messages could introduce incorrect templates in R ind , leading to an unfair comparison between R dst and R ind .However, it is common for the log parsing techniques to identify many templates that are already incorrect [24].Furthermore, the focus of RQ2 is not the correctness of templates but rather the distinguishability of log parsing results.Our goal is to generate a pair of R dst and R ind that are as similar as possible except for the distinguishability property.Indeed, the testing datasets for R dst and R ind are the same in terms of log messages and their order.The only difference lies in how individual log messages are mapped to the templates, affecting the distinguishability of log parsing results.Consequently, the only difference between R dst and R ind is in their distinguishability, ensuring that no bias is introduced when evaluating the model's performance.
Algorithm 1 summarizes the above-mentioned idea into the pseudocode for generating R ind from R dst .After initializing R ind (line 1) as a copy of R dst , the algorithm extracts the set of templates T of R dst (line 2) and sorts the templates in T in ascending order by the number of matching messages (line 3).The algorithm then iteratively merges the last n templates (starting from n = 2 as initialized at line 4) in the sorted templates list Ts (i.e., merging the top-n templates that have the highest number of matching templates) until R ind becomes indistinguishable (lines 5-8).Notice that the while loop does not continue endlessly since R ind must be indistinguishable when n becomes |Ts| (i.e., all templates are merged into one) by definition.The algorithm ends by returning R ind .When d(R) = F (i.e., R = R ind ), although one could do the dual of merging templates (i.e., dividing templates), it would require to determine which templates to divide and how many templates to generate from a given template.Instead, we adopted another heuristic: we removed the normal (or abnormal) logs that are indistinguishable from abnormal (or normal) logs.This is based on our observation Fig.

Treatment for Anomaly Detection Techniques using Semantic Information of Templates
Some of the anomaly detection techniques (i.e., LogRobust [52], PLELog [51], LogAnomaly [31]) use the semantic information of templates, instead of simply using template IDs, by converting them into semantic vectors [23].For these techniques, two templates are considered "identical" if their semantic vectors are similar enough.Therefore, the notion of "identical" templates for determining the distinguishability of log parsing results must be revised in terms of the semantic vectors used by these anomaly detection techniques; otherwise, simply determining the distinguishability based on their template IDs would be meaningless for these techniques.To do this, for each log parsing result R, we applied a clustering algorithm to the semantic vectors of all templates and considered the templates in the same cluster to be identical.Specifically, we used DBSCAN [2] for clustering since it does not require the number of clusters as an input parameter.For instance, in the above example τ with m 1 and m 3 , if the semantic vectors of τ (m 1 ) and τ (m 3 ) belong to the same cluster, then the templates of m 1 and m 3 are considered the same.Note that the semantic vectors are carefully designed to capture subtle semantic nuances and are able to identify semantically similar log templates while distinguishing different ones [52].Therefore, clustering these semantic vectors can effectively identify "identical" templates for the semantic-based anomaly detection techniques.We then followed the same heuristics described above to generate R ′ from R based on the clustered templates.

Additional Analysis: Degree of Distinguishability
So far, we have described how to compare distinguishable and indistinguishable log parsing results to answer RQ2, treating distinguishability as a binary property (i.e., either distinguishable or indistinguishable) following the original definition [44].Although we have effectively minimized the difference between distinguishable and indistinguishable log parsing results to make a fair comparison, we have applied an artificial process for generating indistinguishable log parsing results from distinguishable ones (or vice versa).To address this limitation, we present an additional analysis on the degree of distinguishability of the log parsing results generated for RQ1.
However, defining a metric to measure the degree of distinguishability is not straightforward, mainly because the original definition of distinguishability is too strict; for example, the log parsing result of two log sequences representing the same behavior can be considered distinguishable simply when they are different in length.Therefore, we present a metric to measure the degree of distinguishability based on the number of common templates between normal and abnormal log sequences.This is based on the observation that a higher number of shared templates between normal and abnormal log sequences indicates weaker distinguishability.
Specifically, recall that we can consider a log parsing result τ * * (L) of a set of log sequences L for a log parsing technique τ .Let c(τ * * (L)) be the number of unique templates in τ * * (L).We define the distinguishability score distScore(τ, L) of L for τ as the ratio of the number of common templates generated by τ between normal and abnormal log sequences to the number of unique templates in all log sequences in L, i.e., distScore(τ, L) = 1 − c(τ * * (Ln)∩τ * * (La)) , where Ln and La are the sets of normal and abnormal log sequences in L, respectively.Since c(τ * * (L)) = c(τ * * (Ln)) ∪ c(τ * * (La)), the distinguishability score is effectively the Jaccard distance between Ln and La in terms of their templates.For example, the number of unique templates identified by Drain for the HDFS dataset is 31.Among them, 13 templates appear in both normal and abnormal log sequences.Therefore, the distinguishability score of Drain for the HDFS dataset is 1 − 13 31 = 0.57.We want to note that, ideally speaking, this additional analysis should allow us to measure the impact of distinguishability on anomaly detection accuracy in a more fine-grained manner without generating artificial log parsing results.However, our metric is a heuristic and may not fully capture the various aspects of distinguishability.Therefore, we will use this new analysis as a complementary study to the main analysis (treating distinguishability as a binary property), to provide a more comprehensive understanding of the impact of distinguishability on anomaly detection accuracy.

RQ1: Relationship between Log Parsing Accuracy and Anomaly Detection Accuracy
All 13 log parsing techniques and 7 anomaly detection techniques completed their executions on the HDFS and Hadoop datasets.However, none of the anomaly detection techniques detected abnormal logs in the OpenStack dataset (i.e., the F1 score is zero).This could be due to the very small number of abnormal logs in the dataset (only 4 out of 2068, as reported in Table 2).Therefore, we disregard the results for OpenStack.For all tuples ⟨GA, PA, FTA, PR, RE , F1 ⟩ we collected for HDFS and Hadoop, Fig. 2 and Fig. 3 show the relationship between ⟨GA, PA, FTA⟩ (x-axis) and F 1 (y-axis) for HDFS and Hadoop, respectively, in the form of a scatter plot.To additionally distinguish the main results for different anomaly detection techniques, we used different shapes and colors: = DeepLog, = LogAnomaly, = LogRobust, = CNN, = PLELog, = SVM, and = RF.For example, the top left subfigure in Fig. 2 shows 13 data points where 13 log parsing techniques are used in combination with DeepLog.All the raw data are available in the replication package on Figshare [25].
Table 3 additionally shows the values of the Spearman's rank correlation coefficient σ⟨X , Y ⟩ between X = ⟨GA, PA, FTA⟩ and Y = F 1 for each pair of anomaly detection technique and dataset.The value of σ⟨X , Y ⟩, ranging between −1 and +1, is an indication of the strength of the monotonic (not necessarily linear) relationship between X and Y ; when σ⟨X , Y ⟩ ≥ +0.7 (or σ⟨X , Y ⟩ ≤ −0.7), there is a strong positive (or negative) correlation between X and Y [1].Note that, on the Hadoop dataset, σ⟨X , Y ⟩ could not be computed for DeepLog, LogAnomaly, LogRobust, and CNN since the F1 score does not vary at all with ⟨GA, PA, FTA⟩, indicating no relationship.3 clearly show that there is no strong correlation between ⟨GA, PA, FTA⟩ and F 1 in all the cases where ⟨GA, PA, FTA, PR, RE , F1 ⟩ tuples were successfully collected.For example, in Fig. 2, LogAnomaly ( ) achieved an F1 score ranging between 0.2 and 0.5 regardless of the GA score.This means that increasing log parsing accuracy does not necessarily increase (or decrease) anomaly detection accuracy.This is counter-intuitive since anomaly detection uses log parsing results, and having "better" log parsing results is expected to increase anomaly detection accuracy.However, this happens because even inaccurate log parsing results can lead to accurate anomaly detection results, for reasons explained below.
To better understand the reason for the above results, let us consider the following two extreme cases separately: (C1) The log parsing accuracy values for input logs are the same, but the resulting anomaly detection accuracy values are different (i.e., the data points located on the same vertical lines in Fig. 2 and Fig. 3).(C2) The log parsing accuracy values for input logs are different, but the resulting anomaly detection accuracy values are the same (i.e., the data points located on the same horizontal lines in Fig. 2 and Fig. 3).
To identify the root cause of C1, we manually investigated several pairs of data points in Fig. 2 and Fig. 3, such as two different HDFS log parsing results having almost the same log parsing accuracy value (GA scores of 0.37 and 0.40) but resulting in significantly different anomaly detection accuracy values (F1 scores of 0.73 and 0.10) for the same anomaly detection technique (DeepLog).It turned out that, although the log parsing accuracy values are similar, the sets of correctly parsed log messages are different.This happened because the log parsing accuracy metrics (GA, PA, and FTA) summarize the log parsing results based on an implicit assumption that all log messages (and templates) are equally important.However, this assumption does not hold when it comes to anomaly detection, which must discriminate different log message templates to learn abnormal sequences of templates.Therefore, this mismatch of assumptions between log parsing and anomaly detection leads to case C1.
As for case C2, similar to the above case, we manually investigated several pairs of data points in Fig. 2 and Fig. 3, such as two different Hadoop log parsing results having significantly different log parsing accuracy values (GA scores of 0.12 and 0.77) but resulting in the same anomaly detection value (F1 score of 0.98) for the same anomaly detection technique (DeepLog).We found that anomaly detection techniques can distinguish between normal and abnormal patterns even when input log message templates are incorrect.To best explain this using a simplified example, let us consider a normal log ln = ⟨m n 1 , m n 2 , . . .⟩ and an abnormal log la = ⟨m a 1 , m a 2 , . . .⟩, where m x i indicates the i-th log message in lx for x ∈ {n, a}.Using oracle templates, we can group the log messages having the same template and represent ln and la as groups; specifically, let gorc(lx) be a sequence of message group indices (i.e., the i-th element of gorc(lx) is the message group index of m x i ).In this context, let us take two logs from the Hadoop dataset as a concrete example where gorc(ln) = ⟨1, 2, 3, 4, . . .⟩ and gorc(la) = ⟨5, 5, 5, 6, . . .⟩.When templates generated by LogMine are used to group messages instead of oracle templates, the sequences of message group indices change to g LM (ln) = ⟨1, 2, 3, 3, . . .⟩ and g LM (la) = ⟨7, 8, 9, 10, . . .⟩.These are clearly different from gorc(ln) and gorc(la), respectively; in particular, m n 3 and m n 4 are incorrectly grouped together in g LM (ln) while m a 1 , m a 2 , and m a 3 are incorrectly separated in g LM (la).The incorrect groupings of LogMine clearly reduce the GA score (as well as PA and TA scores since incorrect groupings imply incorrect templates).However, even the incorrect g LM (ln) and g LM (la) are still different enough from each other for anomaly detection techniques to distinguish between normal and abnormal patterns.This example not only shows why case C2 happened, but also demonstrates the importance of distinguishability in log parsing results for anomaly detection; we will further investigate this aspect in RQ2.
Before we conclude RQ1, one might be curious to know why DeepLog, LogAnomaly, LogRobust, and CNN result in the same anomaly detection accuracy value on the Hadoop dataset (as shown in Figure 3 [GA-Hadoop] and Table 3).This happens because (1) the test set of Hadoop contains only 11 logs (1 normal and 10 abnormal logs, although the number of log messages is in the same order of magnitude as HDFS; see Table 2 for more details) and ( 2) the four anomaly detection techniques classified all the 11 logs in the test set as abnormal.We speculate that PLELog shows different results from the other anomaly detection techniques because PLELog uses a very different deep learning model (i.e., an attention-based GRU [5]).Notice that, in all cases, the results still corroborate that log parsing accuracy and anomaly detection accuracy do not have any strong relationship.
We want to note that the log parsing accuracy results shown in Fig. 2 and Fig. 3 are inconsistent with the ones reported in previous studies [6,53] since the latter only considered 2K log messages, randomly sampled from the original logs, to assess log parsing accuracy.
The answer to RQ1 is that there is no strong correlation between log parsing accuracy and anomaly detection accuracy; increasing log parsing accuracy does not necessarily increase anomaly detection accuracy, regardless of the metric (GA, PA, or TA) used for measuring log parsing accuracy.

Distinguishability as a Binary Property
Tables 4 and 5 show the anomaly detection accuracy values (F1 scores) when different log parsing techniques (rows) and anomaly detection techniques (columns) are used together on the HDFS (reduced) dataset; under each of the anomaly detection technique columns, sub-columns R dst and R ind indicate the F1 scores for distinguishable and indistinguishable log parsing results, respectively, and ∆ indicates the difference between R dst and R ind .For example, if we choose AEL for log parsing and DeepLog for anomaly detection, the F1 score decreases from 0.747 to 0.561 when R ind is used instead of R dst .The same structure applies to Tables 6 and 7, which show the results on the Hadoop dataset.In Table 6, except for PLELog, SVM, and RF, the values for all anomaly detection techniques are identical due to the reasons explained in the last paragraph of Section 5.1.We do not provide results for the OpenStack dataset due to the reasons mentioned in Section 5.1.In all cases, ∆ is non-negative, ranging from 0 (LogCluster-SVM on the HDFS dataset) to 0.9 (Drain/SHISO-PLELog on the Hadoop dataset).This means that the anomaly detection accuracy decreases up to 90 percentage points (pp) when R ind is used instead of R dst .To see if the differences between R dst and R ind are significant, we applied the non-parametric Wilcoxon signed rank test [49] for paired samples to the F1 scores of R dst and R ind , for each of the seven anomaly detection techniques and the two datasets.The results show that, for all the anomaly detection techniques and datasets, the differences between R dst and R ind are significant (p-value < 0.005) in terms of anomaly detection accuracy.
Considering the definition of distinguishability for log parsing results, it is intuitive that indistinguishable log parsing results should lead to lower anomaly detection accuracy.However, it is surprising that this decrease in accuracy is, in some cases, rather limited, e.g., only 0.011 for SHISO on the Hadoop dataset when SVM is used for log parsing.This happens because an indistinguishable log parsing result may only have a few logs that are indistinguishable in terms of normal and abnormal behavior.Recall that we did not explicitly control the number of indistinguishable logs since we aimed to minimize the difference between distinguishable and indistinguishable versions of each log parsing result as described in Section 4.5.Nevertheless, the results shown in Tables 4 and 6 are sufficient to confirm the strong impact of distinguishability in log parsing results on anomaly detection accuracy.
The answer to RQ2 is that the impact of the distinguishability of log parsing results on anomaly detection accuracy is significant for all anomaly detection techniques.

Degree of Distinguishability
Fig. 4: Relationship between distScore and AD Accuracy (HDFS) As explained in Section 4.5.4,let us consider the degree of distinguishability of the log parsing results generated for RQ1 (without considering the artificially generated pairs of R dst and R ind .)We focus on the HDFS dataset for this analysis since we know from the RQ1 results that (1) none of the anomaly detection techniques detected abnormal logs in the OpenStack dataset, and (2) most of the anomaly detection techniques have achieved the same accuracy on the Hadoop dataset.Nevertheless, to avoid drawing conclusions based on a single dataset, we also include another dataset, BGL, in this analysis.Although it was excluded from the previous analyses due to the unavailability of source code (which is essential to measure log parsing accuracy), it can be used to investigate the relationship between the degree of distinguishability and anomaly detection accuracy.To use the BGL dataset, we first reduced it following the same methodology we used for the other datasets (see Section 4.1).Since the dataset has only one extremely long normal log, we created log sequences using a sliding window with a window size of 10, following existing studies [27,51].We then labelled each log sequence as normal or abnormal as follows: If a log sequence contains at least one abnormal log message, it is considered abnormal; otherwise, it is considered normal.In total, we used 275 306 normal and 16 413 abnormal log sequences from the BGL dataset.
HDFS dataset.Fig. 4 shows the relationship between the degree of distinguishability (i.e., the distScore, shown in the x-axis) and the anomaly detection accuracy (i.e., the F1-score, shown in the y-axis) for the HDFS dataset.Each sub-figure corresponds to a different anomaly detection technique, and each data point represents a log parsing technique.The Spearman correlation coefficient between the distScore and the F1-score is also shown in each sub-figure.For DeepLog, Fig. 5: Relationship between distScore and AD Accuracy (BGL) LogAnomaly, LogRobust, and CNN, the F1-score mostly increases with the distinguishability score, except for an outlier around distScore = 0.99.This means that the anomaly detection accuracy mostly improves when the log parsing results are more distinguishable, except for the outlier.This outlier is due to LogCluster, which generates an exceptionally high number of templates, 39 998, while the number of oracle templates is only 26 as noted in Table 2.Although such a large number of templates leads to a high degree of distinguishability between normal and abnormal log sequences due to the high specificity of the templates, it also leads to an excessive number of "features" to consider for the learning-based anomaly detection techniques, making the learning from training data more difficult, resulting in decreased anomaly detection accuracy.For the ML-based anomaly detection techniques, i.e., SVM and RF, the F1-score remains similar regardless of the distinguishability score, except for the same outlier discussed above.We suspect that this is mainly because the traditional ML-based techniques are more sensitive to the number of features they use for learning (i.e., the number of templates, which typically range from 26 to 201) than to the degree of distinguishability.However, LogCluster notably identifies a significantly higher number of templates, totaling 39 998.For PLELog, the F1-score does not show a clear correlation with the distinguishability score.This could be mainly due to the unique architecture of PLELog, which uses Gated Recurrent Units (GRUs) to model the log sequences, as discussed in Section 5.1.
BGL dataset.Fig. 5 shows the results for the BGL dataset.The structure of the figure is the same as that of Fig. 4. Overall, the F1-score mostly increases with the distinguishability score, except for LogAnomaly and SVM.However, their Spearman correlations are very weak (only −0.06 and −0.13, respectively).In other cases, the Spearman correlations are positive, ranging from 0.16 (RF) to 0.70 (LogRobust).This implies that the findings from the HDFS dataset are generally consistent with those from the BGL dataset.
To sum up, although the degree of distinguishability of log parsing results is not always positively related to anomaly detection accuracy, most of the deep learning-based techniques show moderate and positive correlations between the distinguishability degree and the anomaly detection accuracy.Considering the heuristic nature of the proposed distinguishability score, defining a more sophisticated and precise metric that can better capture the relationship between the distinguishability of log parsing results and the anomaly detection accuracy is an interesting direction for future work.
The additional analysis for RQ2 shows that the degree of distinguishability of log parsing results is positively and moderately correlated with the accuracy of most deep learning-based anomaly detection techniques, but not for traditional machine learning-based techniques.This implies that distinguishability should be considered for deep learning-based log parsing for anomaly detection, and calls for defining more sophisticated metrics for measuring the degree of distinguishability.

Threats to Validity
The used oracle templates determine log parsing accuracy values.For example, as noted by Khan et al. [24], manually extracting oracle templates by investigating log messages without accessing the corresponding source code could result in biased, incorrect oracle templates.This could be a significant threat to the validity of our results.To mitigate this, we perused the source code (of the exact version that generated the logs) for each software system and used the templates directly extracted from the source code.Although this made us exclude a few log datasets whose source code was unavailable, it was beneficial to ensure the validity of our results.
Individual log parsing and anomaly detection techniques have distinct hyperparameters, which might significantly affect the log parsing and anomaly detection results.To mitigate this, we used the same hyper-parameter values proposed by the authors, when available; otherwise, we ran preliminary experiments and used the values that resulted in the same results reported in the corresponding papers.
Using a specific set of log datasets is a potential threat to external validity.Though the datasets we considered include the logs of various systems, we had to select HDFS, Hadoop, and OpenStack due to the reasons discussed in Section 4.1.Therefore, even though the datasets have been widely used in existing literature [4,27] on log-based anomaly detection, they may not capture diverse characteristics of log data.Further experiments with different datasets are required to improve the generalizability of our results.
In RQ2, we artificially generated pairs of distinguishable and indistinguishable log parsing results to systematically assess the impact of the distinguishability of log parsing results on anomaly detection accuracy using balanced data.To mitigate any bias introduced during the process, we carefully designed Algorithms 1 and 2 to minimize the difference between each pair of log parsing results, except for their distinguishability property.Note that, although the pair generation process (by merging templates) might look unrealistic, it reflects what frequently happens in real-world scenarios; for example, it is not uncommon for log parsing techniques to misidentify templates so that messages with different oracle templates are mapped to the same (misidentified) template.

Findings and Implications
One of the most surprising results from our evaluation is that, using all existing log parsing accuracy metrics in the literature, we did not find any significant correlation with anomaly detection accuracy.In other words, more accurate log parsing results are not necessarily better for anomaly detection accuracy.This implies that log parsing accuracy is not a good indicator of the quality of log parsing results for anomaly detection purposes.As explained with an example in Section 5.1, this happens because inaccurate log parsing results can still be useful for anomaly detection as long as normal and abnormal logs are distinguishable.At the extreme, a log parsing result R 50 with 50% accuracy could be better for anomaly detection than a log parsing result R 100 with 100% accuracy if R 50 distinguishes normal and abnormal logs while R 100 does not.This could happen when, for example, the log quality is poor (e.g., because of inconsistencies between the developers' intentions and concerns on logging and the actual logging statements in the source code [41]) to the point that even using oracle templates cannot fully distinguish all normal log sequences from abnormal ones.This surprising finding leads to an important practical implication: When used for anomaly detection purposes, we can no longer choose a log parsing technique based on accuracy.Instead, as shown in Section 5.2, the distinguishability of log parsing results should be the main selection criterion.For example, since normal and abnormal logs are often used for training anomaly detection models, candidate log parsing results should be compared in terms of their capability to distinguish normal and abnormal logs.If there are multiple techniques that can equally distinguish between normal and abnormal logs, then the one with the lowest number of identified templates would be preferred since reducing the number of templates would increase the performance of anomaly detection by reducing dimensionality (i.e., the number of features considered in machine learning models) [44].
Note that the notion of distinguishability for log parsing results is irrelevant if these results are not used for anomaly detection.However, if anomaly detection needs log parsing (which is frequently the case in practice), then considering distinguishability can help engineers select the most suitable log parsing technique for anomaly detection.
One may rightfully think that it is intuitive that the distinguishability of log parsing results is essential for learning-based anomaly detection techniques, which distinguish between normal and abnormal log sequences by using the log parsing results (i.e., templates) as learning features.However, despite the prevalent use of log parsing in anomaly detection, the importance of distinguishability has been surprisingly ignored in the log analysis community.This paper aims to highlight the significance of distinguishability in log parsing for anomaly detection.Furthermore, this is the first work to empirically demonstrate the importance of distinguishability after the theoretical framework proposed by Shin et al. [44].
Though our objective here is not to identify the "best" log parsing and anomaly detection techniques, through our experiments, we found that there is no single best technique that significantly outperforms the others in all cases.In the future, to develop better log parsing techniques targeting anomaly detection, it would beneficial to focus on distinguishability, which has not been the case so far.

Related Work
Although individual techniques for log parsing and anomaly detection have been studied for a long time, systematic studies covering several techniques have only recently begun to emerge.For example, the most comprehensive evaluation studies on many log parsing techniques [6,24,53] were conducted over the last four years.Similarly, the relationship between log parsing and anomaly detection has received little attention until very recently.Below, we summarize the recent studies related to this topic.Shin et al. [44] presented the first theoretical study considering the relationship between log parsing and anomaly detection.As described in Section 2.4, they established the concept of ideal log parsing results for anomaly detection.We adopted their theoretical foundation, especially the notion of distinguishability in log parsing results, and empirically showed that distinguishability is indeed essential for anomaly detection.To the best of our knowledge, our work is the first empirical study showing the importance of log parsing distinguishability for anomaly detection.
As explained in Section 3, Le and Zhang [27] presented an empirical study on factors that could affect anomaly detection accuracy.Although a part of their study investigated the impact of log parsing on anomaly detection accuracy, they investigated four log parsing techniques but did not assess the impact of log parsing accuracy.As a result, they only showed that using different log parsing techniques leads to different anomaly detection accuracy scores.In our study, on the other hand, we explicitly measured log parsing accuracy, collected 160 pairs of log parsing accuracy and anomaly detection accuracy values using different combinations of log parsing and anomaly detection techniques, and showed that there is no strong correlation between log parsing accuracy and anomaly detection accuracy.
During the writing of this paper, Fu et al. [12] also presented an empirical study on the impact of log parsing on anomaly detection performance.Although their motivation and research questions are close to ours, there are several key differences.First, for measuring log parsing accuracy, they used the manually generated, error-prone oracle templates [24] provided with the 2K log messages randomly sampled by Zhu et al. [53].In other words, only a very small fraction of the logs used for anomaly detection was used to measure log parsing accuracy in their study.In our study, however, the same logs used for anomaly detection are used to measure log parsing accuracy, and the oracle templates are directly extracted from the corresponding source code.Second, they considered only one log parsing accuracy metric (GA), whereas we considered all three log parsing metrics (GA, PA, and TA) since different metrics assess complementary aspects of log parsing [24].Third, log parsing distinguishability, which is an essential factor that substantially affects anomaly detection accuracy (as shown in our RQ2), is only considered in our study.Finally, they only considered two deep learningbased anomaly detection techniques (DeepLog and LogRobust), and focused also on more traditional machine learning approaches (such as Principal Component Analysis, clustering, logistic regression, and decision trees).Such differences allow us to report new findings and provide concrete recommendations, as summarized in Section 6.
Wu et al. [50] recently presented an empirical study on the effectiveness of log representation for machine learning-based anomaly detection.They considered different log representation techniques, such as FastText [22], Word2Vec [33], TF-IDF [42] and BERT [7], used to convert textual log data into numerical feature vectors for machine learning algorithms, such as Support Vector Machine, Logistic Regression, Random Forest, CNN, and LSTM.As a part of their study, they investigated the impact of log parsing on anomaly detection when used with different log representation techniques (in particular, FastText and Word2Vec).The empirical results showed that, in general, using log parsing (i.e., Drain [14]) improves the quality of log representations (over raw, unparsed data) and thereby the performance of anomaly detection; they also reported that some models (e.g., CNN and LSTM) are less sensitive to whether the log data is parsed or not, possibly due to the strong feature extraction and representation ability, and can offset the impact of noise generated by log parsing.In addition to these results, they also investigated the impact of additionally refining log parsing results using regular expressions and the impact of using different log parsing techniques.The results showed that refining log parsing results do not significantly increase anomaly detection performance but using different log parsing techniques yields slight variations in anomaly detection performance.However, for these additional investigations, they used only one anomaly detection technique (i.e., Logistic Regression) and two log parsing techniques (i.e., Drain [14] and LogPPT [28]).Furthermore, they did not study the relationship between log parsing accuracy and anomaly detection accuracy.On the contrary, we use 13 log parsing techniques and 5 DL-based anomaly detection techniques to comprehensively investigate the relationship between log parsing accuracy and anomaly detection accuracy.
Table 8 summarizes the key differences between the closely-related previous empirical studies (i.e., Le and Zhang [27], Fu et al. [12]) and our work.

Conclusion and Future Work
In this paper, we reported on a comprehensive empirical study investigating the impact of log parsing on anomaly detection accuracy, using 13 log parsing techniques, five DL-based and two ML-based anomaly detection techniques on three publicly available log datasets.When analyzing log parsing results for anomaly detection, we were surprised not to find any significant relationship between log parsing accuracy and anomaly detection accuracy, regardless of metric used for the former (including GA, PA, and FTA).This implies that, as opposed to common research practice to date, we can no longer select a log parsing technique purely based on its accuracy when used for anomaly detection.Instead, we experimentally confirmed existing theoretical results showing that the distinguishability of log parsing results plays an essential role in achieving accurate anomaly detection.It is therefore highly recommended to consider distinguishability when utilizing log parsing results as input for anomaly detection.
As part of future work, we plan to extend our study with more publicly available datasets and log parsing techniques [28,46], which were published during the writing of this paper, to increase the generalizability of our results.We also aim to include state-of-the-art few-shot anomaly detection techniques [18,39], which require only a limited amount of training data and could be more effective in practice.We also plan to provide a more granular analysis of distinguishability for log parsing results by defining a new metric that assesses the degree of distinguishability.Finally, we plan to assess the performance of anomaly detection techniques that do not require log parsing [26,35,37].

Data Availability
The replication package of our empirical evaluation (including the Python implementations for log parsing techniques, anomaly detection techniques, helper scripts, and datasets) is available on Figshare [25].

Algorithm 1 : 7 R 8 n ← n + 1 9
Generating an indistinguishable log parsing result from a distinguishable one Input : Distinguishable Log Parsing Result R dst Output: Indistinguishable Log Parsing Result R ind 1 Log Parsing Result (Set of Parsed Logs) R ind ← copy(R dst ) 2 Set of Templates T ← getTemplates(R dst ) 3 Sorted List of Templates Ts ← sortByNumMessages(T ) 4 Integer n ← 2 5 while d(R ind ) = True do 6 Set of Templates Tm ← getLastTemplates(Ts, n) ind ← mergeTemplates(Tm, R dst ) return R ind 4.5.2Generation of Distinguishable from Indistinguishable Log Parsing Results

Table 2 :
Size information of the log datasets used in our experiments.Number of oracle templates (O); Number of all logs (L all ); Number of normal logs (Ln ); Number of abnormal logs (La ); Number of all messages (M all ); Number of messages in normal logs (Mn ); Number of messages in abnormal logs (Ma ).
1: An example of making a distinguishable log parsing result indistinguishable by merging templates that, when d(R) = F , only a small number of normal and abnormal logs are indistinguishable.To minimize the impact of removing logs, we removed normal logs when the total number of normal logs is larger than that of abnormal logs (as it is the case for the HDFS dataset); otherwise, we removed abnormal logs (in the case of the Hadoop dataset).Specifically, only MoLFI, SLCT, LogCluster, and LFA generated indistinguishable log parsing results for HDFS in the first place, and we only removed 5, 5, 9, and 2 logs, respectively, out of 15026 normal logs.Algorithm 2 shows how to generate R dst from R ind based on the above idea.It first extracts the set of indistinguishable logs L ind from R ind (line 1).It then removes either normal or abnormal logs in L ind from R ind to generate R dst depending on the total number of normal and abnormal logs (lines 2-5).Since R dst is the result of removing indistinguishable (normal or abnormal) logs from R ind , R dst is distinguishable.The algorithm ends by returning R dst .

Table 3 :
Spearman correlation coefficients between log parsing accuracy (GA, PA, and FTA) and anomaly detection accuracy (F1 score)

Table 4 :
Impact of the distinguishability log parsing results on anomaly detection accuracy for the HDFS (reduced) dataset (DL-based anomaly detection techniques)

Table 5 :
Impact of the distinguishability of log parsing results on anomaly detection accuracy for the HDFS (reduced) dataset (ML-based anomaly detection techniques)

Table 6 :
Impact of the distinguishability of log parsing results on anomaly detection accuracy for the Hadoop dataset (DL-based anomaly detection techniques)

Table 7 :
Impact of the distinguishability of log parsing results on anomaly detection accuracy for the Hadoop dataset (ML-based anomaly detection techniques)

Table 8 :
Comparison with related empirical studies